package com.scy.hospitalmanager.controller;

import com.scy.hospitalmanager.pojo.Nurse;
import com.scy.hospitalmanager.pojo.NurseTransition;
import com.scy.hospitalmanager.service.NurseTransitionService;
import com.scy.hospitalmanager.until.GetPageNum;
import com.scy.hospitalmanager.until.ResponseMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: 护士审批
 * @ClassName: NurseTransitionController
 * @Author: KuonnjiArisu
 * @Date: 2021/9/8 13:51
 * @Version: 1.0
 */
@Controller
public class NurseTransitionController {
    @Autowired
    NurseTransitionService nurseTransitionService;
    @PostMapping("/getAllTransition")
    @ResponseBody
    public ResponseMap getAllTransition(@RequestBody GetPageNum getPageNum){

        getPageNum.setPageSize(8);
        System.out.println(getPageNum);
        if (getPageNum.getPageNo() == 0) {
            getPageNum.setPageNo(1);
        }
        return ResponseMap.OK(nurseTransitionService.getAllNurseTransition(getPageNum));

    }
    @PostMapping("/insertNurseTransition")
    @ResponseBody
    public ResponseMap insertNurseTransition(@RequestBody NurseTransition nurseTransition){
        if (nurseTransition!=null){
            return ResponseMap.OK(nurseTransitionService.insertNurseTransition(nurseTransition));
        }else {
            return ResponseMap.NO("插入失败");
        }

    }
    @PostMapping("/updateNurseTransition")
    @ResponseBody
    public ResponseMap updateNurseTransition(@RequestBody NurseTransition nurseTransition){
        if (nurseTransition!=null){
            return ResponseMap.OK(nurseTransitionService.updateNurseTransition(nurseTransition));
        }else {
            return ResponseMap.NO("更新失败");
        }
    }
    @PostMapping("/deleteNurseTransition")
    @ResponseBody
    public ResponseMap deleteNurseTransition(@RequestBody NurseTransition nurseTransition){
        if (nurseTransition!=null){
            return ResponseMap.OK(nurseTransitionService.deleteNurseTransition(nurseTransition));
        }else {
            return ResponseMap.NO("删除失败");
        }
    }
    @PostMapping("/getNurseTransitionByTrId")
    @ResponseBody
    public ResponseMap getNurseTransitionByTrId(@RequestBody NurseTransition nurseTransition){
        if (nurseTransition!=null){
            return ResponseMap.OK(nurseTransitionService.getNurseTransitionByTrId(nurseTransition));
        }else {
            return ResponseMap.NO("查找失败，传参为空！");
        }
    }
}
